//
//  SexViewController.m
//  SDHuiYuShoping
//
//  Created by luojiao on 2017/6/20.
//  Copyright © 2017年 luojiao. All rights reserved.
//

#import "SexViewController.h"

@interface SexViewController ()

{
    UIButton *selectButton;
}
@end

@implementation SexViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置返回按钮
    [self.backButton setImage:[UIImage imageNamed:@"back_white_btn"] forState:UIControlStateNormal];
    [self.backButton setImageEdgeInsets:UIEdgeInsetsMake(0, -50, 0, 0)];
    [self.backButton setTitle:@"返回" forState:UIControlStateNormal];
    [self.backButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -40, 0, 0)];
    
    [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    [self.girlButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -(APP_WIDTH - 50))];
    
    [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    [self.boyButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -(APP_WIDTH - 50))];

    [self.secretButton setImage:[UIImage imageNamed:@"select_btn_sel"] forState:UIControlStateNormal];
    [self.secretButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -(APP_WIDTH - 50))];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //设置状态栏颜色
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - buttonClick
- (IBAction)backButton:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)boyButton:(id)sender
{
    self.secretButton.selected = NO;
    self.girlButton.selected = NO;
    
    UIButton *boyButton = (UIButton *)sender;
    boyButton.selected =! boyButton.selected;
    if (boyButton.selected == YES)
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn_sel"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    }
    else
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    }
    
    if (_delegate && [_delegate respondsToSelector:@selector(choseSexDelegate:)])
    {
        [_delegate choseSexDelegate:@"男"];
        [self.navigationController popViewControllerAnimated:YES];

    }
    
}

- (IBAction)girlButton:(id)sender
{
    self.boyButton.selected = NO;
    self.secretButton.selected = NO;
    
    UIButton *girlButton = (UIButton *)sender;
    girlButton.selected =! girlButton.selected;
    if (girlButton.selected == YES)
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn_sel"] forState:UIControlStateNormal];
    }
    else
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    }
    
    if (_delegate && [_delegate respondsToSelector:@selector(choseSexDelegate:)])
    {
        [_delegate choseSexDelegate:@"女"];
        [self.navigationController popViewControllerAnimated:YES];

    }

}

- (IBAction)secretButton:(id)sender
{
    self.boyButton.selected = NO;
    self.girlButton.selected = NO;
    
    UIButton *secretButton = (UIButton *)sender;
    secretButton.selected =! secretButton.selected;
    if (secretButton.selected == YES)
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn_sel"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    }
    else
    {
        [self.boyButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.secretButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
        [self.girlButton setImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    }
    if (_delegate && [_delegate respondsToSelector:@selector(choseSexDelegate:)])
    {
        [_delegate choseSexDelegate:@"保密"];
        [self.navigationController popViewControllerAnimated:YES];
    }
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
